/**
 * @author joshua
 */
Ext.ns('joshua');//name Space

joshua.url= 'Servicios/s.php';
joshua.PAGINA_CUANTOS= 25;

joshua.HtmlLogin='<div id="loginTodo" ><div id="loginContainer" >' +
		'	<div id="login">' +
		'		<div id ="login-form"></div>' +
		'	</div>' +
		'</div></div>';
joshua.HtmlDesktop='<div id="x-desktop">' +
		'<dl id="x-shortcuts">' +
	'        <dt id="envios-win-shortcut">' +
		'            <a href="#"><img src="./images/s.gif" />' +
		'            <div>Envios</div></a>' +
		'        </dt>' +
	'        <dt id="tema-win-shortcut">' +
		'            <a href="#"><img src="./images/s.gif" />' +
		'            <div>Tema</div></a>' +
		'    </dl>' +
		'</dl>' +
		
		'<div class="widgets_esc"><div class="esc_reloj" id="esc_reloj"></div><div class="esc_calendar" id="esc_calendar"></div><div class="esc_avatar" id="esc_avatar"></div></div>'+
		
		'</div>' +
		'' +
		'<div id="ux-taskbar">' +
		'	<div id="ux-taskbar-start"></div>' +
		'	<div id="ux-taskbuttons-panel"></div>' +
		'	<div id="ux-statusbar" ></div>' +
		'	<div class="x-clear"></div>' +
		'</div>'; 




joshua.funciones = function(){
	return{
		Nivel:function(){
			return (joshua.Nivel=='Administrador');
		},
		CerrarSesion:
			function(){

                Ext.util.Cookies.set("usuario", "");
					var conn=new Ext.data.Connection();
						conn.request({
									url:joshua.url,
									scope:this,
									params:{className:'Session',cmd:'desloguear'},
									success:function(response,opt){	//return;
										setTimeout(function (){window.location.href="index.php";},100);
										//return ;
									},
									failure:function(resp,opt){
										
									}
						});
			
			},
		alert:
			function(tipo,titulo,html){
				new Manduks.Notificacion.Toaster({
										//iconCls:	'x-icon-error',
										tipo:tipo,
										title:titulo,										
										//frame:false,
										hideBorders:true,
										html:'<div style="padding: 7px; font-size:9pt; color:#214376;">'+html+'</div>',										
										autoDestroy: true,
										hideDelay: 8000										
									}).show(document); 
			},
		templatesUnidad:
				function (foto,modelo,lugares,id){//template unidades
				var id=(id)?id+'</br>':'';
			  		return '<div class="udmarcoU">' +
									'<div class="ud_mfoto">' +
										'<img src="./fotos/'+foto+'" class="ud_ffoto">'+										
									'</div>' +
									'<div class="ud_mdetalleU">' +
										'<div class="ud_ndetalle">' +
											id + modelo +										
										'</div>'+
										'<div class="ud_ddetalle">' +
											'<b>Lugares : '+lugares+'</b>' +
										'</div>'+
									'</div>' +
								'</div>' ;
				},//eo fn
		templates:
				function (valor1,valor2,valor3,valor4,icono){//funcion de mostrar ventanas		
					
					valor3=valor3 || '';
					valor4=valor4 || '';
					
			  		var cad= '<div class="udmarco">'+
			  		'<div class="ud_mfoto">'+
			  				'<img src="fotos/'+valor1+'" class="ud_ffoto">'+
			  				'<img src="img/'+icono+'" class="udicono">'+
			  		'</div>'+									
			  		'<div class="ud_mdetalle">'+
			  				'<div class="ud_ndetalle">'+
			  					valor2+
			  				'</div>'+
			  				'<div class="ud_ddetalle">'+
			  					valor3+
			  				'</div>';
			  			cad+=(valor4)?	'<div class="ud_ttdetalle">'+
			  					'<img src="img/telefono.png" class="udfon">'+
			  					'<div class="ud_tdetalle">'+
			  						valor4+
			  					'</div>' +
			  				'</div>':'' ;
			  		cad+='</div>' +
			  		'</div>';
			  		return cad;
				},//eo funciones 
		templatesClientes:
			function (valor1,valor2,valor3,valor4){//funcion de mostrar ventanas
			  	var cad= '<div class="udmarco">'+			  										
			  		'<div class="ud_mdetalle">'+
			  				'<div class="ud_ndetalle">'+
			  					valor2+
			  				'</div>'+
			  				'<div class="ud_ddetalle">'+
			  					valor3+
			  				'</div>';
			  	cad+=(valor4)?	'<div class="ud_ttdetalle">'+
			  						'<img src="img/telefono.png" class="udfon">'+
			  						'<div class="ud_tdetalle">'+
			  							valor4+
			  						'</div>' +
			  					'</div>' :'';			  		
			  	
			  	cad+='</div>' +
			  		'</div>';
			  		
			  	return cad;
			}//eo funciones 
	}
}();//eo FBS.funciones 



/*
Ext.override( Ext.grid.GridPanel, {
	border:false,
	frame:false,
   	stripeRows: true,
 	loadMask:{msg:'Cargando...'},
	viewConfig:{forceFit:true},
    layout:'fit',
	autoWidth:true,
	initComponent : function(){
        Ext.grid.GridPanel.superclass.initComponent.call(this);
		this.view= new Ext.grid.GridView({
		      forceFit:true,
		      enableRowBody:true,
		      ignoreAdd: true,
		      emptyText: '<h6 class="red">No se encontraron registros con esos datos.</h6>'
		});

        if(this.columnLines){
            this.cls = (this.cls || '') + ' x-grid-with-col-lines';
        }
        // override any provided value since it isn't valid
        // and is causing too many bug reports ;)
        this.autoScroll = false;
        this.autoWidth = false;

        if(Ext.isArray(this.columns)){
            this.colModel = new Ext.grid.ColumnModel(this.columns);
            delete this.columns;
        }

        // check and correct shorthanded configs
        if(this.ds){
            this.store = this.ds;
            delete this.ds;
        }
        if(this.cm){
            this.colModel = this.cm;
            delete this.cm;
        }
        if(this.sm){
            this.selModel = this.sm;
            delete this.sm;
        }
        this.store = Ext.StoreMgr.lookup(this.store);

		//agregador por JOSHUA
		this.store.on('loadexception', function() {
  			this.store.removeAll();
		},this);
		
        this.addEvents(
            // raw events
            /**
             * @event click
             * The raw click event for the entire grid.
             * @param {Ext.EventObject} e
             * /
            'click',
            /**
             * @event dblclick
             * The raw dblclick event for the entire grid.
             * @param {Ext.EventObject} e
             * /
            'dblclick',
            /**
             * @event contextmenu
             * The raw contextmenu event for the entire grid.
             * @param {Ext.EventObject} e
             * /
            'contextmenu',
            /**
             * @event mousedown
             * The raw mousedown event for the entire grid.
             * @param {Ext.EventObject} e
             * /
            'mousedown',
            /**
             * @event mouseup
             * The raw mouseup event for the entire grid.
             * @param {Ext.EventObject} e
             * /
            'mouseup',
            /**
             * @event mouseover
             * The raw mouseover event for the entire grid.
             * @param {Ext.EventObject} e
             * /
            'mouseover',
            /**
             * @event mouseout
             * The raw mouseout event for the entire grid.
             * @param {Ext.EventObject} e
             * /
            'mouseout',
            /**
             * @event keypress
             * The raw keypress event for the entire grid.
             * @param {Ext.EventObject} e
             * /
            'keypress',
            /**
             * @event keydown
             * The raw keydown event for the entire grid.
             * @param {Ext.EventObject} e
             * /
            'keydown',

            // custom events
            /**
             * @event cellmousedown
             * Fires before a cell is clicked
             * @param {Grid} this
             * @param {Number} rowIndex
             * @param {Number} columnIndex
             * @param {Ext.EventObject} e
             * /
            'cellmousedown',
            /**
             * @event rowmousedown
             * Fires before a row is clicked
             * @param {Grid} this
             * @param {Number} rowIndex
             * @param {Ext.EventObject} e
             * /
            'rowmousedown',
            /**
             * @event headermousedown
             * Fires before a header is clicked
             * @param {Grid} this
             * @param {Number} columnIndex
             * @param {Ext.EventObject} e
             * /
            'headermousedown',

            /**
             * @event cellclick
             * Fires when a cell is clicked.
             * The data for the cell is drawn from the {@link Ext.data.Record Record}
             * for this row. To access the data in the listener function use the
             * following technique:
             * <pre><code>
function(grid, rowIndex, columnIndex, e) {
    var record = grid.getStore().getAt(rowIndex);  // Get the Record
    var fieldName = grid.getColumnModel().getDataIndex(columnIndex); // Get field name
    var data = record.get(fieldName);
}
</code></pre>
             * @param {Grid} this
             * @param {Number} rowIndex
             * @param {Number} columnIndex
             * @param {Ext.EventObject} e
             * /
            'cellclick',
            /**
             * @event celldblclick
             * Fires when a cell is double clicked
             * @param {Grid} this
             * @param {Number} rowIndex
             * @param {Number} columnIndex
             * @param {Ext.EventObject} e
             * /
            'celldblclick',
            /**
             * @event rowclick
             * Fires when a row is clicked
             * @param {Grid} this
             * @param {Number} rowIndex
             * @param {Ext.EventObject} e
             * /
            'rowclick',
            /**
             * @event rowdblclick
             * Fires when a row is double clicked
             * @param {Grid} this
             * @param {Number} rowIndex
             * @param {Ext.EventObject} e
             * /
            'rowdblclick',
            /**
             * @event headerclick
             * Fires when a header is clicked
             * @param {Grid} this
             * @param {Number} columnIndex
             * @param {Ext.EventObject} e
             * /
            'headerclick',
            /**
             * @event headerdblclick
             * Fires when a header cell is double clicked
             * @param {Grid} this
             * @param {Number} columnIndex
             * @param {Ext.EventObject} e
             * /
            'headerdblclick',
            /**
             * @event rowcontextmenu
             * Fires when a row is right clicked
             * @param {Grid} this
             * @param {Number} rowIndex
             * @param {Ext.EventObject} e
             * /
            'rowcontextmenu',
            /**
             * @event cellcontextmenu
             * Fires when a cell is right clicked
             * @param {Grid} this
             * @param {Number} rowIndex
             * @param {Number} cellIndex
             * @param {Ext.EventObject} e
             * /
            'cellcontextmenu',
            /**
             * @event headercontextmenu
             * Fires when a header is right clicked
             * @param {Grid} this
             * @param {Number} columnIndex
             * @param {Ext.EventObject} e
             * /
            'headercontextmenu',
            /**
             * @event bodyscroll
             * Fires when the body element is scrolled
             * @param {Number} scrollLeft
             * @param {Number} scrollTop
             * /
            'bodyscroll',
            /**
             * @event columnresize
             * Fires when the user resizes a column
             * @param {Number} columnIndex
             * @param {Number} newSize
             * /
            'columnresize',
            /**
             * @event columnmove
             * Fires when the user moves a column
             * @param {Number} oldIndex
             * @param {Number} newIndex
             * /
            'columnmove',
            /**
             * @event sortchange
             * Fires when the grid's store sort changes
             * @param {Grid} this
             * @param {Object} sortInfo An object with the keys field and direction
             * /
            'sortchange',
            /**
             * @event reconfigure
             * Fires when the grid is reconfigured with a new store and/or column model.
             * @param {Grid} this
             * @param {Ext.data.Store} store The new store
             * @param {Ext.grid.ColumnModel} colModel The new column model
             * /
            'reconfigure'
        );
    }
} );
 //==========================================CLASE DE COMBO PARA LAS SUCURSALES=====================================

 // Ext.reg('comboSucursales',joshua.usuarios.SucCombox);
	
	/*
	  
var onloadFunction= function (){
	 Ext.QuickTips.init();


//	joshua.usuarios.ventana_form=undefined;

    var button = Ext.get('show-btn');

    button.on('click', mostrarInterfaz);


//    simple.render(document.body);
}
*/